import {legacy_createStore as createStore ,combineReducers } from 'redux'


function msgReducer(state = {msg:"初始数值12"},action:any){
    switch (action.type){
        case 'changemsg':
            state.msg = action.payload
            return {...state}
        case 'asyncchangemsg':
            console.log(action)
            setTimeout(()=>{
                state.msg = action.payload
               
            },1500)
            return {...state}
        default:
            return state    
    }
}


function numReducer(state = {num:999},action:any){
    switch (action.type){
        case 'changemnum':
            state.num = action.payload
            return {...state}
        default:
            return state    
    }
}

let combine = combineReducers({msgReducer,numReducer})
let store = createStore(combine)

export default store